#include <vector>
class Solution {
public:
    int minimumTotal(vector<vector<int> > &triangle) {
        if(triangle.empty())
        return 0;

        vector<vector<int>> v(triangle);
        int line=triangle.size();
        for(int i=line-2;i>=0;i--)
        {
            for(int j=0;j<=i;j++)
            {
                v[i][j]=min(v[i+1][j],v[i+1][j+1])+triangle[i][j];
            }
        }
        return v[0][0];
    }
};
